#!usr/bin
#对用户输入分数给定等级
df(){
	if (( $1 > 90 && $1 <= 100 )) ;then
		dj='A'
	elif (( $1 > 80 ));then
		dj='B'
	elif (( $1 > 70 ));then
		dj='C'
	elif (( $1 >= 0 ));then
		dj='D'
	fi
}
main(){
	while :
	do
		read -p "请输入分数" score
		#判断输入的分数是数字
		if  echo $score |egrep "^[0-9]+\b" &>/dev/null;then
			#判断数字是否在0-100之间
		      if (( $score >=0 &&  $score <=100 ));then
			      break
		      else
			      echo "请输入0-100之间的数值"
		      fi
		#判断用户输入的是否为空
		elif [[ $score == '' ]];then  
			echo "分数长度不为0"
		fi
	done
	df $score
	echo "您的分数是$dj"
}
main
